package cn.iktz.mather.know.web.utils;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import cn.iktz.mather.know.web.beans.NameValue;

public class ResultUtils {

	public static Map<String, Object> add(Integer responseCode, NameValue... nameValues) {
		return add(responseCode, Arrays.asList(nameValues));
	}

	public static Map<String, Object> add(Integer responseCode, List<NameValue> nameValues) {
		Map<String, Object> result = new HashMap<>();
		for (NameValue nameValue : nameValues) {
			result.put(nameValue.getKey(), nameValue.getValue());
		}
		result.put("responseCode", responseCode);
		return result;
	}

	public static Map<String, Object> add(NameValue... nameValues) {
		Map<String, Object> result = new HashMap<>();
		for (NameValue nameValue : nameValues) {
			result.put(nameValue.getKey(), nameValue.getValue());
		}
		return result;
	}
}
